#include <bits/stdc++.h>
using namespace std;
const int maxn = 100;

char a[maxn][maxn];
int n, m;

int square(int x0, int y0, int xn, int yn) {
	int black = 0;
	int white = 0;
	int count = 0;
	for (int i=x0; i<=xn; i++) {
		for (int j=y0; j<=yn; j++) {
			if (a[i][j] == '1') {
				black ++;
			} else if (a[i][j] == '0') {
				white ++;
			}
			count ++;
		}
	}
	if (black == white) {
		return count;
	}
	return -1;
}
int main() {
	cin >> n >> m;
	for (int i=0; i<n; i++) {
		cin >> a[i];
	}
	
	int max = 0;
	for (int i=0; i<n; i++) {
		for (int j=0; j<m; j++) {
			
			for (int k=i; k<n; k++) {
				for (int g=j; g<m; g++) {
					int ret = square(i, j, k, g);
					if (max < ret) {
						max = ret;
					}	
				} 
			} 
		}
	}
	cout << max << endl;
	return 0;
}
